package com.zlx.xBiaoShop.dao;


import com.zlx.xBiaoShop.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @Description user 数据访问接口
 * @date 2020-12-05 17:52:12
*/
public interface UserDao extends JpaRepository<User,String>, JpaSpecificationExecutor<User> {
    Integer countUserByEmail(String email);

    User findByUsername(String username);

    @Query("update User u set u.password = ?2 where u.username=?1")
    @Modifying
    void updatePassword(String username,String password);

    User findUserByUsernameAndPassword(String username, String password);

    @Query("update User u set u.pic = ?2 where u.id=?1")
    @Modifying
    void updatePic(Integer id,String pic);

    @Query("update User u set u.defaultAddrid = ?2 where u.id=?1")
    @Modifying
    void updateDefalutAddrById(Integer userId, Integer addrId);

    User getByWxOpenid(String wxOpenid);

    User getByQqOpenid(String qqOpenid);
}

